import { FormItemRule } from "naive-ui";
/**
 * 增加表单配置
 */
export const addFormConfig: Record<string, any> = {
  cols: 24,
  xGap:24,
  labelPlacement: 'left',
  labelWidth: 80,
  formItems: [
    {
      field: "create_time",
      labelName: "发布日期",
      labelStyle: "fontSize:14px;",
      type: "Date",
      placeholder: "请选择日期",
      selectWidth: "180px",
      span:12
    },
    {
      field: "public_time",
      labelName: "发布时间",
      labelStyle: "fontSize:14px;",
      type: "Time",
      placeholder: "请选择时间",
      selectWidth: "180px",
      span: 12
    },
    {
      field: "content",
      labelName: "内容",
      labelStyle: "fontSize:14px;",
      type: "TextArea",
      inputType: "textarea",
      placeholder: '请输入内容',
      autosize: {
        minRows: 3,
        maxRows: 5,
      },
      span: 24
    },
  ],
  rules: {
    public_time: {
      required: true,
      trigger: ["input"],
      message: "请选择时间",
      validator(rule: FormItemRule, value: string) {
        if (value.toString().length === 0) {
          return new Error("未选择时间");
        }
        return true;
      },
    },
    create_time: {
      required: true,
      trigger: ["input"],
      message: "请选择日期",
      validator(rule: FormItemRule, value: string) {
        if (value.toString().length === 0) {
          return new Error("未选择日期");
        }
        return true;
      },
    },
    content: {
      required: true,
      trigger: ["input"],
      message: "请输入内容",
      validator(rule: FormItemRule, value: string) {
        if (value.length === 0) {
          return new Error("未输入内容");
        }
        return true;
      },
    },
  }
};


/**
 * 修改表单配置
 */
export const updateFormConfig: Record<string, any> = {
  cols: 24,
  xGap: 24,
  labelPlacement: 'left',
  labelWidth: 80,
  formItems: [
    {
      field: "creater",
      labelName: "发布者",
      labelStyle: "fontSize:14px;",
      type: "Input",
      inputType:'text',
      inputWidth: "180px",
      disabled: true,
      span:12
    },
    {
      field: "create_time",
      labelName: "发布日期",
      labelStyle: "fontSize:14px;",
      type: "Date",
      placeholder: '请选择日期',
      span: 12
    },
    {
      field: "public_time",
      labelName: "发布时间",
      labelStyle: "fontSize:14px;",
      type: "Time",
      placeholder: "请选择时间",
      selectWidth: "180px",
      span: 12
    },
    {
      field: "content",
      labelName: "内容",
      labelStyle: "fontSize:14px;",
      type: "TextArea",
      inputType: "textarea",
      placeholder: '请输入内容',
      autosize: {
        minRows: 3,
        maxRows: 5,
      },
      span: 24
    },

  ],
  rules: {
    create_time: {
      required: true,
      trigger: ["input"],
      message: "请选择日期",
      validator(rule: FormItemRule, value: string) {
        if (value.toString().length === 0) {
          return new Error("未选择日期");
        }
        return true;
      },
    },
    public_time: {
      required: true,
      trigger: ["input"],
      message: "请选择时间",
      validator(rule: FormItemRule, value: string) {
        if (value.toString().length === 0) {
          return new Error("未选择时间");
        }
        return true;
      },
    },
    content: {
      required: true,
      trigger: ["input"],
      message: "请输入内容",
      validator(rule: FormItemRule, value: string) {
        if (value.length === 0) {
          return new Error("未输入内容");
        }
        return true;
      },
    },
  },
};

